
<h3>
<?php
printf("%s %d %s %s<br/>\n",t("Level "), $toon->level, check_plain($toon->race), check_plain($toon->class));
if($toon->guildName) echo l($toon->guildName,'guild/'.$toon->realm.'/'.$toon->guildName);
?>
</h3>

<div>Date first scanned: <?php echo format_date($toon->added_to_database,"small"); ?></div>
<div><?php echo $toon->updated ? t('Last updated: @time ago', array('@time' => format_interval(time() - $toon->updated))) : t('Last checked: never'); ?></div>


<?php
if(count($toon->sets) > 1) {
  echo '<ul class="tabs primary">';
  foreach($toon->sets as $set) {
	echo '<li id="tab' . $set->set_id . '" ' . ($set->active?' class="active"':'') . '>';
    $txt = sprintf('%s %s', wowcore_iconpath(check_plain($set->icon),21), check_plain($set->spec));
    echo l($txt,implode('/',arg()) . '/' . $set->set_id,array('html' => true, 'attributes' => array('rel' => 'charsheet_spec' . $set->set_id, 'class' => 'spec_link')));
    echo "</li>\n";
  }
  echo '</ul><div style="clear:both"></div>';
}
?>
<?php foreach($toon->sets as $set) {
echo '<a name="charsheet_spec' . $set->set_id . '"></a>';
echo '<div id="charsheet_spec' . $set->set_id . '" style="display:' . (($set->active)?'block':'none') . '">';
?>

<div class='spec_text'><?php
$txt = sprintf('%s %s', wowcore_iconpath(check_plain($set->icon),43), check_plain($set->spec));
echo $txt;
?></div>
<table width="500">
<tr><td class="item_popup"><?php wowcharsheet_item_rollover_link($set,0); ?></td>
<td rowspan="7">

<?php
// Display the wowarmory 3D model?
echo $change_3D_link;
if($display_flash_model) {
?>
<iframe src="http://www.wowarmory.com/character-model-embed.xml?r=<?php echo urlencode($toon->realm); ?>&cn=<?php echo urlencode($toon->name); ?>&rhtml=true" scrolling="no" height="588" width="321" frameborder="0"></iframe>
<?php
} else {
?>
  <table class="charsheet_stats_container">
  <tr>
    <td>
	  <table>
	  <?php
	  echo t("<tr><td colspan='2'><p>Base Stats</p></td></tr>\n");
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Strength"),$set->baseStats->strength['effective']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Agility"),$set->baseStats->agility['effective']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Stamina"),$set->baseStats->stamina['effective']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Intellect"),$set->baseStats->intellect['effective']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Spirit"),$set->baseStats->spirit['effective']);
	  ?>

	  </table>

    </td>
    <td>
	  <table>
	  <?php
	  echo t("<tr><td colspan='2'><p>Melee</p></td></tr>\n");
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Attack Power"),$set->melee->power['effective']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Hit Rating"),$set->melee->hitRating['effective']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Crit Chance"),$set->melee->critChance['effective']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Expertise"),$set->melee->expertise['effective']);
	  ?>

	  </table>
	</td>
  </tr>
  <tr>
    <td>
	  <table>
	  <?php
	  echo t("<tr><td colspan='2'><p>Ranged</p></td></tr>\n");
	  printf("<tr><td>%s</td><td>%0.1f</td></tr>",t("DPS"),$set->ranged->damage['dps']);
	  printf("<tr><td>%s</td><td>%0.2f</td></tr>",t("Speed"),$set->ranged->speed['value']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Attack Power"),$set->ranged->power['effective']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Hit Rating"),$set->ranged->hitRating['value']);
	  printf("<tr><td>%s</td><td>%2.2f%%</td></tr>",t("Crit Chance"),$set->ranged->critChance['percent']);
	  ?>

	  </table>

    </td>
    <td>
	  <table>
	  <?php
	  echo t("<tr><td colspan='2'><p>Spell</p></td></tr>\n");
	  $dam = $toon->spell->bonusDamage;
	  $damvalue = min($dam->arcane['value'],$dam->fire['value'],$dam->frost['value'],$dam->holy['value'],$dam->nature['value'],$dam->shadow['value']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Damage"),$damvalue);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Hit Rating"),$set->spell->hitRating['value']);
	  
	  $dam = $toon->spell->critChance;
	  $damvalue = min($dam->arcane['percent'],$dam->fire['percent'],$dam->frost['percent'],$dam->holy['percent'],$dam->nature['percent'],$dam->shadow['percent']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Crit Chance"),$set->spell->critChance['effective']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Penetration"),$set->spell->penetration['value']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Mana Regen"),$set->spell->manaRegen['notCasting']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Healing"),$set->spell->bonusHealing['value']);
	  ?>

	  </table>
	</td>
  </tr>
  <tr>
    <td>
	  <table>
	  <?php
	  echo t("<tr><td colspan='2'><p>Defense</p></td></tr>\n");
    printf("<tr><td>%s</td><td>%d</td></tr>",t("Armor"),$set->baseStats->armor['effective']);
	  printf("<tr><td>%s</td><td>%0.2f</td></tr>",t("Defense"),$set->defenses->defense['value']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Dodge"),$set->defenses->dodge['percent']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Parry"),$set->defenses->parry['percent']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Block"),$set->defenses->block['percent']);
	  printf("<tr><td>%s</td><td>%d</td></tr>",t("Resilience"),$set->defenses->resilience['value']);
	  ?>

	  </table>

    </td>
	<td>&nbsp;</td>
  </tr>
  </table>
	<?php } // Show text toon ?>
</td>
<td class="item_popup"><?php wowcharsheet_item_rollover_link($set,9); ?></td></tr>
<tr><td class="item_popup"><?php wowcharsheet_item_rollover_link($set,1); ?></td>
    <td class="item_popup"><?php wowcharsheet_item_rollover_link($set,5); ?></td></tr>
<tr><td class="item_popup"><?php wowcharsheet_item_rollover_link($set,2); ?></td>
    <td class="item_popup"><?php wowcharsheet_item_rollover_link($set,6); ?></td></tr>
<tr><td class="item_popup"><?php wowcharsheet_item_rollover_link($set,14); ?></td>
    <td class="item_popup"><?php wowcharsheet_item_rollover_link($set,7); ?></td></tr>
<tr><td class="item_popup"><?php wowcharsheet_item_rollover_link($set,4); ?></td>
    <td class="item_popup"><?php wowcharsheet_item_rollover_link($set,10); ?></td></tr>
<tr><td class="item_popup"><?php wowcharsheet_item_rollover_link($set,3); ?></td>
    <td class="item_popup"><?php wowcharsheet_item_rollover_link($set,11); ?></td></tr>
<tr><td class="item_popup"><?php wowcharsheet_item_rollover_link($set,18); ?></td>
    <td class="item_popup"><?php wowcharsheet_item_rollover_link($set,12); ?></td></tr>
<tr><td class="item_popup"><?php wowcharsheet_item_rollover_link($set,8); ?></td>
    <td class="item_popup">
			<?php wowcharsheet_item_rollover_link($set,15); ?>
			<?php wowcharsheet_item_rollover_link($set,16); ?>
		  <?php wowcharsheet_item_rollover_link($set,17); ?>
		</td>
    <td class="item_popup"><?php wowcharsheet_item_rollover_link($set,13); ?></td></tr>
</table>
</div>
<?php
} // END Spec Loop

if($new_items) {
  print("<table id='new_items'>\n");
  print("<tr>\n");
  printf("\t<th>%s</th>\n",t("Recently Aquired Items"));
  print("</tr>\n");
  foreach($new_items as $row) {
    printf("<tr class=\"%s\">\n", ($i++ % 2 == 0?"even":"odd"));
    printf("\t<td>%s</td>\n", $row);
    print("</tr>\n");
  }
  print("</table>\n");
}
if($achevements) {
  print("<table id='recent_achevements'>\n");
  print("<tr>\n");
  printf("\t<th>%s</th>\n",t("Recent Achevements"));
  print("</tr>\n");
  foreach($achevements as $row) {
    printf("<tr class=\"%s\">\n", ($i++ % 2 == 0?"even":"odd"));
    printf("\t<td>%s</td>\n", $row);
    print("</tr>\n");
  }
  print("</table>\n");
}
?>

<div class="clear"><?php echo $links; ?></div>